package com.w7vm.menuweb.message;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

import org.primefaces.context.RequestContext;

public class MessageFaces {
	

	public void sendInfoMessageToUser(String msgTitulo, String msgCorpo){
		FacesContext context = getContext();
		context.addMessage(msgCorpo, new FacesMessage(FacesMessage.SEVERITY_INFO, msgTitulo, msgCorpo));
	}

	public void sendErrorMessageToUser(String msgTitulo, String msgCorpo){
		//FacesContext context = getContext();
		//context.addMessage(msgCorpo, new FacesMessage(FacesMessage.SEVERITY_ERROR, msgTitulo, ""));
		
		 FacesContext.getCurrentInstance().addMessage(msgCorpo, new FacesMessage(FacesMessage.SEVERITY_ERROR," ", msgTitulo)); 
	}

	public FacesContext getContext() {
		FacesContext context = FacesContext.getCurrentInstance();
		return context;
	}
	
	public void showMessage() {
        RequestContext.getCurrentInstance().showMessageInDialog(new FacesMessage(FacesMessage.SEVERITY_INFO, "What we do in life", "Echoes in eternity."));
    }
	

}
